package com.myrslok.install;

import com.myrslok.set.FileResourceSet;
import org.jetbrains.annotations.NotNull;

import java.io.File;

/**
 * Installs Myrslok to the current directory. Given
 * Myrslok.jar and a directory, this class will detect the OS and
 * output a script which runs Myrslok.
 */
public class Installer {

    static final String INSTALL_DIR_PROPERTY_NAME = "install.dir";

    private Installer() {
    }

    /**
     * @return the directory to install to. Default current dir.
     */
    @NotNull
    public static String getInstallDir() {
        return System.getProperty(INSTALL_DIR_PROPERTY_NAME, ".");
    }

    public static void main(@NotNull final String[] args) {
        final File resourceDir = InstallScriptSet.forCurrentOsName().getResourceDir();
        final File installDir = new File(getInstallDir());
        final FileResourceSet fileSet = new FileResourceSet(resourceDir);
        fileSet.copyTo(installDir);
    }


}
